﻿<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>实体资料</title>
    <link rel="stylesheet" type="text/css" href="../Content/Css/OperaMasksUI/default/om-all.css" />
    <link rel="stylesheet" type="text/css" href="../Content/Css/list.css" />
    <script type="text/javascript" src="../Scripts/jquery.1.6.3.min.js"></script>
    <script type="text/javascript" src="../Scripts/json2.js"></script>
    <script type="text/javascript" src="../Scripts/common.js"></script>
    <script type="text/javascript" src="../Scripts/OperaMasksUI/operamasks-ui.min.js"></script>
    <script type="text/javascript" src="../Scripts/Plugin/jquery.form.js"></script>
    <script type="text/javascript" src="../Scripts/OperaMasksUI/Plugin/om-yj-container.js"></script>
    <script type="text/javascript" src="../Scripts/Plugin/artDialog4.1.7/jquery.artDialog.js?skin=default"></script>
    <script type="text/javascript" src="../Scripts/Plugin/artDialog4.1.7/plugins/iframeTools.js"></script>
    <script type="text/javascript">
        var detailPanel, listGrid, detailGrid, colData, detailColData, searchPanel, defaultSort, defaultWhere, validatorForm, submitForm, currentUID, currentGIndex = -1, genRenderCheckbox, genRenderDateformat;
        var showSearchPanel, showToolBar, showDetialForm, controlBtn, oldRowData, detailForm, goOn = true, DoFlag = true, ifh;
        var actionRoot = "../handler/ajax.ashx?type=AjaxSystem", comboxBankData = [], comboxTypeData = [], comboxStatusData = [], genRenderDateformat, genRenderDateformatSS;

        $(document).ready(function () {
            $.ajax({
                cache: false, async: false,
                url: '../handler/ajax.ashx?type=AjaxSystem&method=loginIn',
                dataType: 'json', type: 'post',
                beforeSend: function () {
                    $.omMessageBox.waiting({
                        title: '请等待',
                        content: '服务器正在加载用户信息,请稍后...'
                    });
                },
                complete: function () {
                    $.omMessageBox.waiting("close");
                },
                success: function (data) {
                    if (data.IsError) {
                        goOn = false;
                        $.omMessageBox.alert({
                            content: '发现系统错误,请重新登录<BR>错误码：' + data.Message,
                            onClose: function () {
                                window.top.location.href = decodeURIComponent("../Index.aspx");
                            }
                        });
                    }
                    else {
                        goOn = true;
                        currentUID = data.Data.userid;
                    }
                },
                error: function (result) {
                    goOn = false;
                    $.omMessageBox.alert({
                        content: '发现系统错误,请重新登录<BR>错误码：' + result.status,
                        onClose: function () {
                            window.top.location.href = decodeURIComponent("Index.aspx");
                        }
                    });
                }
            });
            var element = $('body').omBorderLayout({
                fit: true,
                spacing: 0,
                panels: [
                {
                    id: "center-panel",
                    header: false,
                    title: "中间模块",
                    region: "center"
                }, {
                    id: "west-panel",
                    resizable: true,
                    collapsible: true,
                    title: "<span style='color:#15428B;font-weight: bold;padding:6px;'>查询条件</span>",
                    region: "west",
                    width: 230
                },
                {
                    id: "south-panel",
                    region: "south",
                    header: false,
                    resizable: false,
                    collapsible: false,
                    height: 50
                },
                {
                    id: "east-panel",
                    region: "east",
                    header: false,
                    resizable: false,
                    collapsible: false,
                    width: 400
                }
                ]
            });
            showSearchPanel();
            //Grid Column 
            colData = [
                { header: '客户编码', name: 'Code', width: 140, align: 'center' },
                { header: '客户简称', name: 'Short', width: 80, align: 'left' },
                { header: '中文名称', name: 'ChnName', width: 200, align: 'left' },
                { header: '英文名称', name: 'EngName', width: 140, align: 'left' },
                { header: '类型', name: 'Type', width: 50, align: 'center' },
                { header: '中文地址', name: 'ChnAddr', width: 200, align: 'left' },
                { header: '英文地址', name: 'EngAddr', width: 140, align: 'left' },
                { header: '传真', name: 'Fax', width: 80, align: 'left' },
                { header: '邮件', name: 'Email', width: 80, align: 'center' },
                { header: '银行CNY', name: 'ChnBank', width: 200, align: 'left' },
                { header: '账号CNY', name: 'ChnAccountNo', width: 200, align: 'left' },
                { header: '银行USD', name: 'EngBank', width: 80, align: 'left' },
                { header: '账号USD', name: 'EngAccountNo', width: 50, align: 'center' },
                { header: '起始日期', name: 'FromDate', width: 80, align: 'left' },
                { header: '终止日期', name: 'DestDate', width: 50, align: 'center' },
                { header: '结算备注', name: 'SettleNote', width: 80, align: 'left' },
                { header: '结算联系人', name: 'SettleContacter', width: 50, align: 'center' },
                { header: '结算联系人电话', name: 'SettleTel', width: 80, align: 'left' },
                { header: '备注', name: 'Note', width: 120, align: 'center' },
                { header: '创建人', name: 'UserCreate', width: 100, align: 'center' },
                { header: '创建时间', name: 'CreateDate', width: 120, align: 'center', renderer: genRenderDateformat },
                { header: '修改人', name: 'UserModify', width: 100, align: 'center' },
                { header: '修改时间', name: 'ModifyDate', width: 130, align: 'center', renderer: genRenderDateformat }
            ];
            detailColData = [
                { header: '帐套编号', name: 'U8Code', width: 50, align: 'center' },
                { header: '客户编码', name: 'EntityCode', width: 100, align: 'left' },
            ]
            //排序
            defaultSort = { sortby: 'UID', sortdir: 'ASC' };
            //条件
            defaultWhere = { where: ' 1=1 ' };
            //初始化
            listGrid = $('#listgrid').omGrid({
                width: '100%',
                height: 'fit',
                //title: '用户列表',
                singleSelect: true,
                onRowClick: function (rowIndex, rowData, event) {
                    detailGrid.omGrid({
                        extraData: $.extend({ where: " EntityID = '" + rowData.UID + "'" }, { sortby: 'UID', sortdir: 'ASC' }),
                        dataSource: '../Handler/grid.ashx?view=vEntitySubject',
                    });
                },
                limit: 20,
                extraData: $.extend(defaultWhere, defaultSort),
                dataSource: "{rows:[],total:0}",
                colModel: colData
            });
            detailGrid = $('#detailgrid').omGrid({
                width: '100%',
                height: 'fit',
                //title: '部门列表',
                singleSelect: true,
                limit: 20,
                extraData: $.extend(defaultWhere, defaultSort),
                dataSource: "{rows:[],total:0}",
                colModel: detailColData
            });
        });

        genRenderCheckbox = function (colValue, rowData, rowIndex) {
            if (colValue) {
                return '<input type="checkbox" id="00" checked="checked" disabled="disabled"></input>';
            }
            return '<input type="checkbox" id="01" disabled="disabled"></input>';
        }

        genRenderDateformatSS = function (colValue, rowData, rowIndex) {
            if (colValue.length == 0 || colValue == null) {
                return '';
            }
            else {
                if (colValue.indexOf("/Date") > -1)
                    return new Date(parseInt(colValue.replace("/Date(", "").replace(")/", ""), 10)).Format("yyyy-MM-dd");
                else
                    return colValue;
            }
        }

        genRenderDateformat = function (colValue, rowData, rowIndex) {
            if (colValue.length == 0 || colValue == null) {
                return '';
            }
            else {
                if (colValue.indexOf("/Date") > -1)
                    return new Date(parseInt(colValue.replace("/Date(", "").replace(")/", ""), 10)).Format("yyyy-MM-dd hh:mm");
                else
                    return colValue;
            }
        }
        //查询语句
        showSearchPanel = function () {
            $("#button-search").click(function () {
                var custWhere = '';
                custWhere += ' AND Code LIKE ' + '\'%' + $("#search-panel input[id='Code']").val() + '%\'';
                custWhere += ' AND Short LIKE ' + '\'%' + $("#search-panel input[id='Short']").val() + '%\'';
                custWhere += ' AND ChnName LIKE ' + '\'%' + $("#search-panel input[id='ChnName']").val() + '%\'';
                listGrid.omGrid({
                    extraData: $.extend({ where: defaultWhere.where + custWhere }, defaultSort),
                    dataSource: '../Handler/grid.ashx?view=vEntity'
                });
                detailGrid.omGrid({
                    dataSource: ''
                });
            });
            $('#button-clear').click(function () {
                $("div[id='search-panel'] input").val("");
            });
        };
    </script>
</head>
<body>
    <div id="west-panel" class="westpanel">
        <div id="search-panel">
            <table>
                <tr>
                    <td style="width: 60px" align="right">
                        <span class="label">实体编码</span>
                    </td>
                    <td>
                        <input type="text" class="input-text" id="Code" />
                    </td>
                </tr>
                <tr>
                    <td style="width: 60px" align="right">
                        <span class="label">实体简称</span>
                    </td>
                    <td>
                        <input type="text" class="input-text" id="Short" />
                    </td>
                </tr>
                <tr>
                    <td style="width: 60px" align="right">
                        <span class="label">实体名称</span>
                    </td>
                    <td>
                        <input type="text" class="input-text" id="ChnName" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div id="center-panel">
        <table id="listgrid"></table>
    </div>
    <div id="east-panel">
        <table id="detailgrid"></table>
    </div>
    <div id="south-panel">
        <table style="margin-top: 5px; margin-left: 20px;">
            <tr>
                <td>
                    <input id="button-search" type="button" class="btnCss" value="搜    索" />
                    <input id="button-clear" type="button" class="btnCss" value="清    空" style="margin-left: 20px;" />
                </td>
            </tr>
        </table>
    </div>
</body>
</html>
